//    Copyright (C) Kherty.  All rights reserved.
#region

using OpenLS.Core.Serialization;
using OpenLS.Vml.Drawing;
using OpenLS.Vml.Serialization;

#endregion

namespace OpenLS.Vml
{
    public class Background : IOfficeXmlSerializable
    {
        private BWMode? _bwmode;
        private BWMode? _bwnormal;
        private BWMode? _bwpure;
        private EditAs? _editas;
        private Fill _fill;
        private string _id;
        private ScreenSize? _targetscreensize;

        public Fill Fill
        {
            get { return _fill; }
            set { _fill = value; }
        }

        #region IOfficeXmlSerializable Members

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read("background"))
            {
                _id = c.GetOptionalString("id");
                _editas = c.GetOptionalEnum<EditAs>("editas");
                _bwmode = c.GetOptionalEnum<BWMode>(VmlConstants.OfficeNamespace + "bwmode");
                _bwpure = c.GetOptionalEnum<BWMode>(VmlConstants.OfficeNamespace + "bwpure");
                _bwnormal = c.GetOptionalEnum<BWMode>(VmlConstants.OfficeNamespace + "bwnormal");
                _targetscreensize = c.GetOptionalEnum<ScreenSize>(VmlConstants.OfficeNamespace + "targetscreensize");
                Fill = c.ReadOptionalElement<Fill>("fill");
            }
        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write("background"))
            {
                c.SetOptionalString("id", _id);
                c.SetOptionalEnum("editas", _editas);
                c.SetOptionalEnum(VmlConstants.OfficeNamespace + "bwmode", _bwmode);
                c.SetOptionalEnum(VmlConstants.OfficeNamespace + "bwpure", _bwpure);
                c.SetOptionalEnum(VmlConstants.OfficeNamespace + "bwnormal", _bwnormal);
                c.SetOptionalEnum(VmlConstants.OfficeNamespace + "_targetscreensize", _targetscreensize);
                c.WriteOptionalElement(Fill);
            }
        }

        #endregion
    }
}